// 导出模块
import Vue from "vue"
import Vuex from "vuex"
import { get, post } from "../util/api"
Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        companyList: [], // 企业列表
        recentlyVisit: [], // 最近返回的定位
        cityInfo: {} // 分站城市判断
    },
    mutations: {
        addCompanyList(state, companyList) {
            state.companyList = companyList
        },
        addRecentlyVisit(state, recentlyVisit) {
            state.recentlyVisit = recentlyVisit
        },
        setIsShowError(state, cityInfo) {
            state.cityInfo = cityInfo
        },
    },
    actions: {
        getCityNameError ({ commit }) {
            return new Promise((resolve, reject) => {
                get("/bmj-api/api/sys/depart/getSubInfo",{}).then(res => {
                    commit('setIsShowError', res.result)      
                })
            })
        }
    }
})
export default store